/**************************************************************************
*   Copyleft 2009 by        											  *
*	Iwanicki Krzysztof													  *
*   <www.gamma.mini.pw.edu.pl/~iwanickik>		                          *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
***************************************************************************/
#ifndef __VFREELOOKCAMERA_H__
#define __VFREELOOKCAMERA_H__

#include "./vCamera.h"
#include "../Input/vMouseListener.h"
#include "../Input/vKeybordListener.h"

namespace Vendetta {

	/*! \class vFreeLookCamera
	 *  \brief A vFreeLookCamera class implements simple Free look camera mode.
	 *
	 */
	class vFreeLookCamera: public vCamera, public vMouseListener, public vKeyboardListener {
		friend class vSceneManager;
	public:
		/*! \brief Implementation from vCamera.
		 *
		 *	\sa		vCamera.
		 *	\sa		vFrameListener::vFrameEvent.
		 */
		vVoid Update(const vFrameListener::vFrameEvent& event);

		/*! \brief Implementation from vMouseListener.
		 *
		 *	\sa		vMouseListener.
		 */	
		vVoid MouseMoved(const vMouseListener::MouseEvent& event);

		/*! \brief Implementation from vMouseListener.
		 *
		 *	\sa		vMouseListener.
		 */	
		vVoid MousePressed(const vMouseListener::MouseEvent& event);

		/*! \brief Implementation from vMouseListener.
		 *
		 *	\sa		vMouseListener.
		 */	
		vVoid MouseReleased(const vMouseListener::MouseEvent& event);

		/*! \brief Implementation from vKeyboardListener.
		 *
		 *	\sa		vKeyboardListener.
		 */	
		vVoid KeyPressed(const vKeyboardListener::KeyboardEvent& event);

		/*! \brief Implementation from vKeyboardListener.
		 *
		 *	\sa		vKeyboardListener.
		 */
		vVoid KeyReleased(const vKeyboardListener::KeyboardEvent& event);

	protected:
		/*! \brief Rotates camera around the position (and axis) for specified angle.
		 *
		 *	\param		rAngle			Angle of rotation (in radians).
		 *	\param		axis			Axis to rotate over.
		 */	
		virtual vVoid rotateView(vReal rAngle, const vVector3D& axis);

		/*! \brief Strafes camera left or right depending on the speed (-/+).
		 *
		 *	\param		rSpeed			Speed of strafe.
		 */	
		virtual vVoid strafe(vReal rSpeed);

		/*! \brief Move camera forward or backward depending on the speed (-/+).
		 *
		 *	\param		rSpeed			Speed of movement.
		 */	
		virtual vVoid move(vReal rSpeed);

	private:
		/*! \brief Constructor.
		 *
		 *	Note:	See vCamera for more details.
		 *
		 *	\param		name			Camera name.
		 */	
		vFreeLookCamera(const vString& name);

		/*! \brief Destructor.
		 *
		 */	
		virtual ~vFreeLookCamera();

		//! Disabled - if You call this You get exception.
		vFreeLookCamera();

		//! Disabled - if You call this You get exception.
		vFreeLookCamera(const vFreeLookCamera& camera);

		//! Disabled - if You call this You get exception.
		vFreeLookCamera& operator=(const vFreeLookCamera& camera);

	private:
		vReal		mCurrentRot;			//! Rotation angle to avoid 360 loop.
		vPoint2D	mLastMouseCoords;		//! Last mouse coordinates.
		vBool		mWasLeftButtonDown;		//! Holds info about left mouse button;
		vBool		mForwardKeyDown;		//! Holds info about forward key button;
		vBool		mBackwardKeyDown;		//! Holds info about backward key button;
		vBool		mStrafeLeftKeyDown;		//! Holds info about strafe left key button;
		vBool		mStrafeRightKeyDown;	//! Holds info about strafe right key button;
	};
}

#endif // __VFREELOOKCAMERA_H__